package com.csx.ai.spring.ai;

import org.springframework.ai.document.Document;
import org.springframework.ai.reader.tika.TikaDocumentReader;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.Resource;

import java.util.List;

/**
 * @author cuisongxu
 * @date 2025/6/8 周日 19:29
 */
@SpringBootApplication
public class SpringAiApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringAiApplication.class, args);
    }

    @Value("classpath:/BurgerBattle-rules.txt")
    Resource documentResource;

    @Bean
    ApplicationRunner go(VectorStore vectorStore) {
        return args -> {
            TikaDocumentReader reader = new TikaDocumentReader(documentResource);
            List<Document> documents = reader.get();
            vectorStore.add(documents);
        };
    }
}
